﻿using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;

using LogAnalyzerIIS.Properties;

namespace LogAnalyzerIIS
{
	public partial class ThisAddIn
	{
		private void ThisAddIn_Startup(object sender, System.EventArgs e)
		{
			this.Application = (Excel.Application)ExcelLocale1033Proxy.Wrap(typeof(Excel.Application), this.Application);

			try
			{
				// create the application folder if it doesn't already exist
				string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Resources.APPLICATION_FOLDER_NAME;

				if (!Directory.Exists(path))
					Directory.CreateDirectory(path);

				// Create the session folder if it doesn't already exist
				path += ("\\" + Resources.SESSIONS_FOLDER_NAME);

				if (!Directory.Exists(path))
					Directory.CreateDirectory(path);
			}
			catch (Exception exception)
			{
				MessageBox.Show(exception.ToString());
			}
		}

		private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
		{
		}

		#region VSTO generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InternalStartup()
		{
			this.Startup += new System.EventHandler(ThisAddIn_Startup);
			this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
		}


		#endregion
	}
}
